﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package org.aswing {
    import org.aswing.geom.*;
    import org.aswing.event.*;
    import org.aswing.plaf.basic.*;
    import flash.ui.*;

    public class JTextField extends JTextComponent {

        private static var defaultMaxChars:int = 0;

        private var columns:int;

        public function JTextField(_arg1:String="", _arg2:int=0){
            setName("JTextField");
            getTextField().multiline = false;
            getTextField().text = _arg1;
            setMaxChars(defaultMaxChars);
            this.columns = _arg2;
            addEventListener(FocusKeyEvent.FOCUS_KEY_DOWN, this.__onFocusKeyDown);
            this.updateUI();
        }
        public static function setDefaultMaxChars(_arg1:int):void{
            defaultMaxChars = _arg1;
        }
        public static function getDefaultMaxChars():int{
            return (defaultMaxChars);
        }

        override public function updateUI():void{
            setUI(UIManager.getUI(this));
        }
        override public function getDefaultBasicUIClass():Class{
            return (BasicTextFieldUI);
        }
        override public function getUIClassID():String{
            return ("TextFieldUI");
        }
        public function setColumns(_arg1:int=0):void{
            if (_arg1 < 0){
                _arg1 = 0;
            };
            if (this.columns != _arg1){
                this.columns = _arg1;
                revalidate();
            };
        }
        public function getColumns():Number{
            return (this.columns);
        }
        public function addActionListener(_arg1:Function, _arg2:int=0, _arg3:Boolean=false):void{
            addEventListener(AWEvent.ACT, _arg1, false, _arg2, _arg3);
        }
        public function removeActionListener(_arg1:Function):void{
            removeEventListener(AWEvent.ACT, _arg1);
        }
        override protected function isAutoSize():Boolean{
            return ((this.columns == 0));
        }
        override protected function countPreferredSize():IntDimension{
            var _local1:int;
            var _local2:int;
            var _local3:int;
            var _local4:IntDimension;
            if (this.columns > 0){
                _local1 = getColumnWidth();
                _local2 = ((_local1 * this.columns) + getWidthMargin());
                _local3 = (getRowHeight() + getHeightMargin());
                _local4 = new IntDimension(_local2, _local3);
                return (getInsets().getOutsideSize(_local4));
            };
            return (getInsets().getOutsideSize(getTextFieldAutoSizedSize()));
        }
        private function __onFocusKeyDown(_arg1:FocusKeyEvent):void{
            if (_arg1.keyCode == Keyboard.ENTER){
                dispatchEvent(new AWEvent(AWEvent.ACT));
            };
        }

    }
}//package org.aswing 
